require(['jquery','token','common/data','sweetalert'], function($,token,syncData,swal) {
    var pageData=syncData.fetch();
    pageData.selectItem=[];
    var content=new Vue({
        el: '.content',
        data:pageData,
        filters:{
            currency: {
                read: function (val) {
                    val=+val;
                    return val.toFixed(2)
                },
                // write 函数会在数据写入到模型之前被调用
                write: function (val, oldVal) {
                    var number = +val.replace(/[^\d.]/g, '')
                    return isNaN(number) ? 0 : parseFloat(number.toFixed(2))
                }
            },
            shopLink: function(val){
                console.log(val);
                var shopId=val;
                return '/shop/'+val;
            }

        },
        methods:{
          submit:function(){
              var userId=this.$data.userBaseInfo._id;
              var shopId=this.$data.shop._id;
              var dish=this.$data.dish;
              var totalPrice=this.$data.totalPrice;
              var sellerPhone=this.$data.shop.phone;
              var buyerPhone=this.$data.userBaseInfo.phone;
              var buyerAddress=this.$data.userBaseInfo.address;
              $.ajax({
                  url:'/api/order',
                  method:'post',
                  data:{
                      userId:userId,
                      shopId:shopId,
                      totalPrice:totalPrice,
                      sellerPhone:sellerPhone,
                      buyerPhone:buyerPhone,
                      buyerAddress:buyerAddress,
                  },
                  success:function(data){

                  }
              })
          }
        }
    })
});